executionContexts
Type
property
Summary
Reports information on the current state of the running application.
Syntax
get the executionContexts
Description
Use the executionContexts property to obtain information about the state of your program, particularly when debugging and error handling.
The last line of the executionContexts represents the current context, i.e. the line of code last executed.
A common use of the executionContexts is to obtain the name of the object and handler that called the current handler, this information is available as: line -2 of the executionContexts.
- if the function call occurred in a behavior script, then the line number refers to the behavior script, not the target script.
The executionContexts property is read-only and cannot be set.
The value of the executionContexts may be changed in future versions of LiveCode, it is not recommended to write code that depends on its contents.
Examples
on errorDialog
local tContextArray
local tHandler, tLineNumber, tObject
put parsedContext(line -2 of the executionContexts) into tContextArray
if tContextArray["behavior"] is empty then
put tContextArray["object"] into tObject
else
put tContextArray["behavior"] into tObject
end if
put tContextArray["handler"] into tHandler
put tContextArray["line"] into tLineNumber
answer "An error occurred at line" && tLineNumber && "in handler" && tHandler && "of" && tObject
end errorDialog
function parsedContext pContextLine
local tKey = "object", tContextA
repeat for each item tItem in pContextLine
if tContextA[tKey] is not empty then
put comma after tContextA[tKey]
end if
put tItem after tContextA[tKey]
switch tKey
case "object"
if exists(tContextA[tKey]) then
put "handler" into tKey
end if
break
case "handler"
put "line" into tKey
break
case "line"
put "behavior" into tKey
break
end switch
end repeat
end parsedContext
Related
message: errorDialog
Compatibility and Support
Introduced
LiveCode 1.1
OS
mac
windows
linux
ios
android
Platforms
desktop
server
mobile